package com.dfk.bs.service.admin.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dfk.bs.dao.admin.AdminMapper;
import com.dfk.bs.entity.admin.Admin;
import com.dfk.bs.service.admin.AdminService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {


    @Override
    public void pageQuery(Page<Admin> pageParam, String selectname) {
        QueryWrapper<Admin> queryWrapper=new QueryWrapper<>();

        /*查询出来排序 根据表中的sort字段排序*/
        queryWrapper.orderByAsc("sort");
        if (selectname==null){
            baseMapper.selectPage(pageParam,queryWrapper);
            return;
        }

        /*两个条件  根据用电器id或者状态搜索分页*/

        if (!StringUtils.isEmpty(selectname) ) {
            queryWrapper.like("username", selectname);
        }

        baseMapper.selectPage(pageParam,queryWrapper);

    }
}
